package cn.tutu.blockchain.controller;

import org.hibernate.validator.constraints.NotBlank;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.github.pagehelper.PageInfo;

import cn.tutu.blockchain.cktrecord.entity.CktRecord;
import cn.tutu.blockchain.cktrecord.service.CktRecordService;
import cn.tutu.blockchain.common.MsgObj;
import cn.tutu.blockchain.common.Page;

@RestController
@RequestMapping("cktRecord")
public class CktRecordController {

	@Autowired
	private CktRecordService cktRecordService;

	@RequestMapping("/getGridByUser")
	public MsgObj getGridByUser(@NotBlank(message = "用户ID不能为空!") String userId, Page page) {
		PageInfo<CktRecord> byModel = cktRecordService.getByUserId(userId, page);
		return MsgObj.buildSuccessObj(byModel.getList());
	}
	
	@RequestMapping("/getGridByCkt")
	public MsgObj getGridByCkt(@NotBlank(message = "用户ID不能为空!") String cktId, Page page) {
		PageInfo<CktRecord> byModel = cktRecordService.getByCktId(cktId, page);
		return MsgObj.buildSuccessObj(byModel.getList());
	}

}
